package zerous.craft;

import android.app.*;
import android.os.*;
import android.view.*;
import android.widget.*;

import zerous.craft.entity.Player.STATE;
import android.view.View.*;
import zerous.craft.entity.*;

public class MainActivity extends Activity
{
	Button jump,left,right,bottom;
	public static int Tx,Ty;
    @Override
    public void onCreate(Bundle savedInstanceState)
	{
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
		
		jump = (Button)findViewById(R.id.Jump);
		left = (Button)findViewById(R.id.Left);
		right = (Button)findViewById(R.id.Right);
		bottom = (Button)findViewById(R.id.Bottom);
		
		jump.setOnTouchListener(new GameListener());
		left.setOnTouchListener(new GameListener());
		right.setOnTouchListener(new GameListener());
		bottom.setOnTouchListener(new GameListener());
		
		if(GameButton.b)
		{
			Toast.makeText(this,"Toush!",Toast.LENGTH_LONG);
		}
    }

	@Override
	public boolean onTouchEvent(MotionEvent event)
	{
		Tx = (int)event.getX();
		Ty = (int)event.getY();
		return true;
	}
}
class GameListener implements OnTouchListener
{
	@Override
	public boolean onTouch(View v,MotionEvent event)
	{
		switch(v.getId())
		{
			case R.id.Jump:
				if(event.getAction() == MotionEvent.ACTION_DOWN)
					Player.state = STATE.Jump;
				else if(event.getAction() == MotionEvent.ACTION_UP)
					Player.state = STATE.Idel;
					
				
				break;
					
			case R.id.Left:
				if(event.getAction() == MotionEvent.ACTION_DOWN)
					Player.state = STATE.Left;
				else if(event.getAction() == MotionEvent.ACTION_UP)
					Player.state = STATE.Idel;
				break;
			case R.id.Right:
				if(event.getAction() == MotionEvent.ACTION_DOWN)
					Player.state = STATE.Right;
				else if(event.getAction() == MotionEvent.ACTION_UP)
					Player.state = STATE.Idel;
				break;
			/*case R.id.Bottom:
				if(event.getAction() == MotionEvent.ACTION_DOWN)
					Player.state = STATE.Bottom;
				else if(event.getAction() == MotionEvent.ACTION_UP)
					Player.state = STATE.Idel;
				break;*/
			
		}
		return true;
	}
}



